let mongoose = require('./db')
const ObjectId = mongoose.Schema.Types.ObjectId

let UserSchema = new mongoose.Schema({
  username: { type: String, required: true },
  code: { type: String, required: true },
  sex: { type: Number, required: true, default: 0 }, //性别
  phone: String, //电话号码
  tencent: String,
  army: { type: Number, required: true, default: 0 },
  createAs: { type: Number, required: true, default: 0 }, // 创建缘由
  tag: [{ type: ObjectId, required: true, ref: 'Tag' }], // 身份标签
  allowance: [{ type: ObjectId, required: true, ref: 'Allowance' }], //所属群组集id 享受补助
  family: [{ type: ObjectId, ref: 'Family' }],
  address: String,
  remark: String, //个人信息
  headPicture: String,
  pages: String, // 照片列表
  state: { type: Number, required: true, default: 200 }, //当前状态
  creator: { type: ObjectId, required: true, ref: 'Admin' }
}, {
  collection: 'User', timestamps: true
})

const User = mongoose.model('User', UserSchema)

module.exports = User
